package com.shopping.mall.core.config;

import com.shopping.mall.core.module.goods.entity.Goods;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;

import java.rmi.UnknownHostException;

@Configuration
public class RedisBeanConfig {

    @Bean
    public RedisTemplate<String, Goods> GoodsRedisTemplate(RedisConnectionFactory redisConnectionFactory) throws UnknownHostException {
        RedisTemplate<String, Goods> template = new RedisTemplate<>();
        template.setConnectionFactory(redisConnectionFactory);
        //序列化器
        Jackson2JsonRedisSerializer<Goods> ser = new Jackson2JsonRedisSerializer<Goods>(Goods.class);
        template.setDefaultSerializer(ser);
        int[] a=new int[2];
        return template;
    }

}
